package com.example.controller;

import com.example.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.Duration;
import java.util.UUID;

/**
 * 本类用来演示:
 *
 * @Author 胡英俊
 * @Date 2022/7/21 22:35
 */
@RestController
public class loginController {
    @Autowired
    private StringRedisTemplate redisTemplate;

    @GetMapping("login")
    public String getLogin(String name,String passWord){
        User user = new User(1,name,passWord,"男");
        String token = UUID.randomUUID().toString();
        redisTemplate.opsForValue().set(token,user.toString(), Duration.ofSeconds(7200));
        return token;
    }
}
